<template>
	<view class="report_show flex_col al_center">
		<component :is="ptype" :reportDetail="reportDetail"></component>
	</view>
</template>

<script>
	import show1 from './components/off_report.vue'
	import show2 from './components/time_reporting.vue'
	import show3 from './components/work_report.vue'
	export default {
		data() {
			return {
				pageType: '',
				reportDetail: null
			};
		},
		computed: {
			ptype: function() {
				let name = ''
				if (this.pageType == 'am') {
					name = 'show3'
				}
				if (this.pageType == 'pm') {
					name = 'show1'
				}
				if (this.pageType == 'driverreport') {
					name = 'show2'
				}
				return name
			}
		},
		components: {
			show1,
			show2,
			show3
		},
		methods: {
			getreportDetail(id) {
				let _this = this
				console.log("id=="+id)
				this.$utils.http.post('/dailywork/detail/driver/' + id).then(res => {
					if (res.code === 200) {
						console.log(JSON.stringify(res.data))
						_this.reportDetail = res.data
					}
				})
			}
		},
		onLoad(options) {
			this.pageType = options.type
			console.log(JSON.stringify(options))
			this.getreportDetail(options.id)
			if (options.type === 'am') {
				uni.setNavigationBarTitle({
					title: '上班日报'
				})
			}
			if (options.type === 'pm') {
				uni.setNavigationBarTitle({
					title: '下班日报'
				})
			}
			if (options.type === 'driverreport') {
				uni.setNavigationBarTitle({
					title: '实时日报'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/common/css/main.css";

	.report_show {
		display: flex;
		width: 750rpx;
	}
</style>
